home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1999 #2
/
Amiga Plus CD - 1999 - No. 2.iso
/
Anwender
/
Grafik
/
PPT
/
rexx
/
InvertAlpha.prx
< prev
next >
Wrap
Text File
|
1998-06-28
|
2KB
|
78 lines
/*
This script takes the existing alpha channel of an image and
turns it to a negative of itself, i.e. where there is no alpha
channel, one is added and where there is already an alpha channel,
it is removed.
Actually, each alpha channel value is replaced with 255-alpha.
$Id:$
*/
/*-------------------------------------------------------------------*/
/* I suggest you use this header as-is and add your own code below */
OPTIONS RESULTS
SIGNAL ON ERROR
IF ADDRESS() = REXX THEN DO
startedfromcli = 1
ADDRESS PPT
END
ELSE DO
startedfromcli = 0
ADDRESS PPT
END
RESULT = 'no result'
/*-------------------------------------------------------------------*/
/* Add your code here */
PARSE ARG frame
IF DATATYPE(frame) ~= NUM THEN DO
RC = 10
RC2 = "No frame selected"
SIGNAL ERROR
END
FRAMEINFO frame STEM inf
IF inf.colorspace ~= ARGB THEN DO
SHOWERROR '"You need an ARGB image for this effect"'
EXIT 10
END
COPYFRAME frame
newframe = RESULT
/* Grab the alpha channel off the image into the RGB channels and make
it negative */
PROCESS newframe COLORMIX RED "0,0,0,100" GREEN "0,0,0,100" BLUE "0,0,0,100"
PROCESS newframe NEGATIVE
/* We remove the now obsolete alpha channel so that we can add it directly
to the image. */
PROCESS newframe TRUECOLOR
PROCESS frame ADDALPHA newframe
/* And finally, cleanup */
DELETEFRAME newframe FORCE
EXIT 0
/*-------------------------------------------------------------------*/
/* Again, keep this part intact. This is the error handler. */
ERROR :
returncode = RC
IF startedfromcli = 1 THEN DO
SAY 'ERROR ' returncode ' on line ' SIGL ': ' RC2
PPT_TO_BACK
END
ELSE
SHOWERROR '"'RC2'"' SIGL
EXIT returncode